home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / sys / dirent.h < prev    next >
C/C++ Source or Header  |  1995-02-14  |  2KB  |  84 lines

  1. /*    @(#)dirent.h    2.1 88/05/18 4.0NFSSRC SMI    */
  2.  
  3. /* 
  4.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  5.  *    1.2 88/02/08 SMI 
  6.  */
  7.  
  8. /*
  9.  * HISTORY
  10.  *  7-Jan-93  Mac Gillon (mgillon) at NeXT
  11.  *    Integrated POSIX changes
  12.  *
  13.  * 19-Dec-88  Peter King (king) at NeXT
  14.  *    Original Sun source: NFSSRC4.0
  15.  */
  16.  
  17. /*
  18.  * Filesystem-independent directory information. 
  19.  * Directory entry structures are of variable length.
  20.  * Each directory entry is a struct dirent containing its file number, the
  21.  * offset of the next entry (a cookie interpretable only the filesystem 
  22.  * type that generated it), the length of the entry, and the length of the 
  23.  * name contained in the entry.  These are followed by the name. The
  24.  * entire entry is padded with null bytes to a 4 byte boundary. All names 
  25.  * are guaranteed null terminated. The maximum length of a name in a 
  26.  * directory is MAXNAMLEN, plus a null byte.
  27.  */
  28.  
  29. #ifndef _SYS_DIRENT_H 
  30. #define _SYS_DIRENT_H 
  31.  
  32. #ifndef KERNEL
  33.     #include <standards.h> 
  34. #endif
  35.  
  36. #if defined(_POSIX_SOURCE) && !defined(KERNEL)
  37.     #include <limits.h>            /* for NAME_MAX */
  38. #endif    /* POSIX_SOURCE && !KERNEL */
  39.     
  40. #if defined(_NEXT_SOURCE)
  41.     #ifndef _MAXNAMLEN
  42.         #define    _MAXNAMLEN
  43.         #define    MAXNAMLEN    255
  44.     #endif /* _MAXNAMLEN */
  45. #endif    /* _NEXT_SOURCE */
  46.  
  47. #if defined(_POSIX_SOURCE) || defined(_NEXT_SOURCE)
  48.  
  49.     struct    dirent {
  50.         off_t   d_off;            /* offset of next */
  51.                         /* disk directory */
  52.                         /* entry */
  53.         unsigned long    d_fileno;    /* file number of */
  54.                         /* entry */
  55.         unsigned short    d_reclen;    /* length of this */
  56.                         /* record */
  57.         unsigned short    d_namlen;    /* length of string */
  58.                         /* in d_name */
  59.     #if defined(_POSIX_SOURCE) && !KERNEL
  60.         char    d_name[NAME_MAX + 1];    /* name (up to */
  61.                         /* NAME_MAX + 1) */
  62.     #else
  63.         char    d_name[MAXNAMLEN + 1];    /* name (up to */
  64.                         /* MAXNAMLEN + 1) */
  65.     #endif    /* _POSIX_SOURCE  && !KERNEL */
  66.     };
  67. #endif  /* _POSIX_SOURCE || _NEXT_SOURCE */
  68.  
  69. #ifdef _NEXT_SOURCE
  70.  
  71.     /* 
  72.      * The macro DIRENTSIZ(dp) gives the minimum amount of space
  73.      * required to represent a directory entry.  For any directory
  74.      * entry dp->d_reclen >= DIRENTSIZ(dp). Specific filesystem
  75.      * types may use this use this macro to construct the value
  76.      * for d_reclen.
  77.      */
  78.     #define DIRENTSIZ(dp)  \
  79.         (((sizeof (struct dirent) - (MAXNAMLEN+1) + \
  80.            ((dp)->d_namlen+1)) + 3) & ~3)
  81.  
  82. #endif /* _NEXT_SOURCE */
  83. #endif /* _SYS_DIRENT_H  */
  84.